#include <gtest/gtest.h>

//class ServiceImpl;
//class ClientImpl;
//class Factory {
//public:
//    ServiceImpl * createServiceImpl(){
//        return nullptr;
//    }
//    ClientImpl * createClientImpl(ServiceImpl * serviceImpl){
//        return nullptr;
//    }
//    ChannelImpl * createChannelImpl(ClientImpl * clientImpl){
//        return nullptr;
//    }
//    ChannelImpl * createChannelImpl(ServerImpl * serverImpl){
//        return nullptr;
//    }
//};

class ServiceImpl{
};
class Service {
public:
    Service()
    : impl(new ServiceImpl)
    {
    }
    ~Service(){
        if(impl != nullptr){
            delete impl;
        }
    }

    ServiceImpl * getServiceImpl(){
        return impl;
    }
    void run(){}

private:
    ServiceImpl * impl;
};

class ClientImpl {
public:
    explicit ClientImpl(ServiceImpl * serviceImpl)
    : serviceImpl(serviceImpl)
    {
    }
    ~ClientImpl(){
    }
private:
    ServiceImpl * serviceImpl;
};
class Client {
public:
    explicit Client(Service & service)
    :service(service)
    , impl(new ClientImpl(service.getServiceImpl()))
    {
    }
    ~Client(){
        if(impl != nullptr){
            delete impl;
        }
    }

    int connect(){
        //Channel * channel(this); 
        //return channel;
        return 0;
    }

    ClientImpl * getClientImpl(){
        return impl;
    }
private:
    Service & service;
    ClientImpl * impl;
};



TEST(MainTest, useService){
    Service service;

    Client client(service); 

    service.run();
}

